package cn.zyq.ykb.controller.mgt.task;

import cn.zyq.ykb.beans.task.TaskPrompt;
import org.springframework.security.access.prepost.PreAuthorize;
import cn.zyq.ykb.system.ry.util.poi.ExcelUtil;
import cn.zyq.ykb.system.common.BaseController;
import cn.zyq.ykb.system.annotation.Log;
import cn.zyq.ykb.system.ry.enums.BusinessType;
import cn.zyq.ykb.service.task.TaskPromptService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import cn.zyq.ykb.system.common.PageParam;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 任务-提示信息Controller
 *
 * @author SystemAuth
 * @date 2023-06-06
 */

@RestController(value = "MgtTaskPromptController")
@RequestMapping("/mgt/taskPrompt")
@Api(tags = "任务-提示信息接口")
public class TaskPromptController extends BaseController {

    @Autowired
    private TaskPromptService taskPromptService;

    /**
     * 查询任务-提示信息列表
     */
    @ApiOperation(value = "列表", response = TaskPrompt.class)
    @PreAuthorize("@ss.hasPermi('ykb:taskPrompt:list')")
    @PostMapping("/list")
    public Object list(@RequestBody PageParam pageParam) {
        return this.taskPromptService.selectTaskPromptList(pageParam);
    }

     /**
      * 导出任务-提示信息列表
      */
     @ApiOperation(value = "导出")
     @PreAuthorize("@ss.hasPermi('ykb:taskPrompt:export')")
     @Log(title = "任务-提示信息" , businessType = BusinessType.EXPORT)
     @PostMapping("/export")
     public void export(HttpServletResponse response, TaskPrompt taskPrompt) {
         List<TaskPrompt> list = taskPromptService.selectTaskPromptList(taskPrompt);
         ExcelUtil<TaskPrompt> util = new ExcelUtil<TaskPrompt>(TaskPrompt. class);
         util.exportExcel(response, list, "任务-提示信息数据");
     }

    /**
     * 获取任务-提示信息详细信息
     */
    @ApiOperation(value = "详情", response = TaskPrompt.class)
    @PreAuthorize("@ss.hasPermi('ykb:taskPrompt:query')")
    @GetMapping(value = "/{taskPrompt}")
    public Object getInfo(@PathVariable("taskPrompt") Integer taskPrompt) {
        return this.taskPromptService.selectTaskPromptByTaskPrompt(taskPrompt);
    }
    /**
     * 获取任务-提示信息详细信息
     */
    @ApiOperation(value = "详情", response = TaskPrompt.class)
    @PreAuthorize("@ss.hasPermi('ykb:taskPrompt:query')")
    @GetMapping(value = "/detail/{serviceID}")
    public Object getInfo(@PathVariable(value = "serviceID") String serviceID) {
        return this.taskPromptService.selectTaskPromptByServiceID(serviceID);
    }

    /**
     * 新增任务-提示信息
     */
    @ApiOperation(value = "新增")
    @PreAuthorize("@ss.hasPermi('ykb:taskPrompt:add')")
    @Log(title = "任务-提示信息", businessType = BusinessType.INSERT)
    @PostMapping
    public Object add(@RequestBody TaskPrompt taskPrompt) {
        return this.taskPromptService.insertTaskPrompt(taskPrompt);
    }

    /**
     * 修改任务-提示信息
     */
    @ApiOperation(value = "编辑")
    @PreAuthorize("@ss.hasPermi('ykb:taskPrompt:edit')")
    @Log(title = "任务-提示信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public Object edit(@RequestBody TaskPrompt taskPrompt) {
        return this.taskPromptService.updateTaskPrompt(taskPrompt);
    }

    /**
     * 删除任务-提示信息
     */
    @ApiOperation(value = "删除")
    @PreAuthorize("@ss.hasPermi('ykb:taskPrompt:remove')")
    @Log(title = "任务-提示信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{taskPrompts}")
    public Object remove(@PathVariable Integer[] taskPrompts) {
        return this.taskPromptService.deleteTaskPromptByTaskPrompts(taskPrompts);
    }
}
